
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 10/27/2010 21:35:11
-- Generated from EDMX file: C:\Users\Jason-Lee\Documents\Visual Studio 2010\Projects\AircraftBattle\AircraftBattle\AircraftBattleDB\AircraftBattleDB.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [AircraftBattle];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[aircraft]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aircraft];
GO
IF OBJECT_ID(N'[dbo].[aircraft_type]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aircraft_type];
GO
IF OBJECT_ID(N'[dbo].[armors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[armors];
GO
IF OBJECT_ID(N'[dbo].[users]', 'U') IS NOT NULL
    DROP TABLE [dbo].[users];
GO
IF OBJECT_ID(N'[dbo].[weapons]', 'U') IS NOT NULL
    DROP TABLE [dbo].[weapons];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'aircraft'
CREATE TABLE [dbo].[aircraft] (
    [id] int IDENTITY(1,1) NOT NULL,
    [type] int  NOT NULL,
    [speed] int  NOT NULL,
    [weapon_id] int  NOT NULL,
    [armor_id] int  NOT NULL
);
GO

-- Creating table 'aircraft_type'
CREATE TABLE [dbo].[aircraft_type] (
    [id] int IDENTITY(1,1) NOT NULL,
    [name] varchar(50)  NOT NULL,
    [image] varchar(50)  NOT NULL,
    [default_speed] int  NOT NULL,
    [default_weapon_id] int  NOT NULL,
    [default_armor_id] int NOT NULL
);
GO

-- Creating table 'armors'
CREATE TABLE [dbo].[armors] (
    [id] int IDENTITY(1,1) NOT NULL,
    [weight] int  NOT NULL,
    [protection] int  NOT NULL
);
GO

-- Creating table 'users'
CREATE TABLE [dbo].[users] (
    [id] int IDENTITY(1,1) NOT NULL,
    [name] varchar(50)  NOT NULL,
    [password] varchar(50)  NOT NULL,
    [isadmin] bit  NOT NULL,
    [craftid] int  NOT NULL,
    [credit] int  NOT NULL,
    [win] int  NOT NULL,
    [lose] int  NOT NULL,
    [kills] int  NOT NULL,
    [blocked] bit  NOT NULL
);
GO

-- Creating table 'weapons'
CREATE TABLE [dbo].[weapons] (
    [id] int IDENTITY(1,1) NOT NULL,
    [damage] int  NOT NULL,
    [shoot_rate] int  NOT NULL,
    [bullet_speed] int  NOT NULL,
    [bullet_size] int  NOT NULL,
    [bullet_type] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [id] in table 'aircraft'
ALTER TABLE [dbo].[aircraft]
ADD CONSTRAINT [PK_aircraft]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'aircraft_type'
ALTER TABLE [dbo].[aircraft_type]
ADD CONSTRAINT [PK_aircraft_type]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'armors'
ALTER TABLE [dbo].[armors]
ADD CONSTRAINT [PK_armors]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'users'
ALTER TABLE [dbo].[users]
ADD CONSTRAINT [PK_users]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'weapons'
ALTER TABLE [dbo].[weapons]
ADD CONSTRAINT [PK_weapons]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------